<?php
namespace common\models;

use common\base\BModel;
use Yii;
class YanseImageUrlModel extends BModel
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'image_url';
    }

    /**
     * @db
     */
    public static function getDb()
    {
        return Yii::$app->get('yanse');
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'image_id'], 'integer'],
            [['url'], 'string', 'max' => 200],
            [['image_id','url'], 'required', 'on' => ['add'], 'message' => '{attribute}不能为空'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'image_id' => '图片父级id',
            'url'=> '连接'
        ];
    }

    /**
     * 保存前
     * @param bool $insert
     * @return bool
     */
    public function beforeSave($insert)
    {
        if(parent::beforeSave($insert)){
            $time = time();
            if($this->isNewRecord){
            }
            return true;
        }
        return false;
    }
}
